{template 'common/header'}
{template 'plugin/navs'}
{template 'navs'}

<link href="../addons/imeepos_runner/plugin/template/template/static/style.css" rel="stylesheet">
<link href="../addons/imeepos_runner/plugin/template/template/static/ionic.css" rel="stylesheet">

<div class="panel panel-default" ng-app="FoxEditor" style="background: #f2f2f2">
	<div class="panel-heading">首页设置</div>
	<div class="panel-body" ng-controller="FoxController">
		<div class="fe">
			<div class="fe-phone">
				<div class="fe-phone-left"></div>
				<div class="fe-phone-center">
					<div class="fe-phone-top"></div>
					<div class="fe-phone-main">
						<div id="editor">
							<div ng-repeat="page in pages">
								<div ng-include="'../addons/imeepos_runner/plugin/template/template/temp/show-'+page.temp+'.html'" id="{{page.id}}" mid="{{page.id}}" ng-click="setfocus(page.id,$event)"></div>
							</div>
							<div style="height: 50px;" ng-show="pages[0].params.guide==1"></div>
							<div ng-repeat="Item in Items" class="fe-mod-repeat" ng-mouseover="over(Item.id)" ng-mouseleave="out(Item.id)">
								<div class="fe-mod-move" ng-mouseover="drag(Item.id)" ng-click="setfocus(Item.id,$event)"></div>
								<div ng-include="'../addons/imeepos_runner/plugin/template/template/temp/show-'+Item.temp+'.html'" class="fe-mod-parent" id="{{Item.id}}" ng-show="Item" mid="{{Item.id}}" on-finish-render-filters></div>
								<div class="fe-mod-del" ng-click="delItem(Item.id)">移除</div>
							</div>
							<!-- 浮动按钮 -->
							<div class="fe-floatico" ng-show="pages[0].params.floatico==1" ng-style="{'width':pages[0].params.floatwidth,'top':pages[0].params.floattop}" ng-class="{'fe-floatico-right':pages[0].params.floatstyle=='right'}">
								<img ng-src="{{pages[0].params.floatimg || '../addons/imeepos_runner/plugin/template/template/static/init-data/init-image-7.png'}}" style="height:100%; width: 100%;" ng-click="setfocus('M0000000000000')" />
							</div>
							<!-- 关注按钮 -->
							<div class="fe-guide" ng-click="setfocus('M0000000000000')" ng-show="pages[0].params.guide==1" ng-style="{'display':'block','background-color':pages[0].params.guidebgcolor,'top':'60px','z-index':'890','opacity':pages[0].params.guideopacity}">
								<div class="fe-guide-faceimg"><img src="../addons/imeepos_runner/plugin/template/template/static/init-data/init-icon.png" ng-style="{'border-radius':pages[0].params.guidefacestyle}" /></div>
								<div class="fe-guide-sub" ng-style="{'color':pages[0].params.guidenavcolor,'background-color':pages[0].params.guidenavbgcolor}">{{pages[0].params.guidesub ||'立即关注'}}</div>
								<div class="fe-guide-text" ng-style="{'font-size':pages[0].params.guidesize,'color':pages[0].params.guidecolor}">
									<p ng-class="{'fe-guide-lineheight':pages[0].params.guidetitle2==''}">{{pages[0].params.guidetitle1s || '加关注，做代理。'}}</p>
									<p ng-class="{'fe-guide-lineheight':pages[0].params.guidetitle1==''}">{{pages[0].params.guidetitle2s || '关注公众号，享专属服务'}}</p>
								</div>
							</div>
						</div>
					</div>
					<div class="fe-phone-bottom"></div>
				</div>
				<div class="fe-phone-right"></div>
			</div>

			<div class="fe-panel">
				<div class="fe-panel-menu">
					<div ng-repeat="nav in navs">
						<nav ng-bind="nav.name" ng-click="addItem(nav.id)"></nav>
					</div>
				</div>
				<!-- editor start -->
				<div class="fe-panel-editor" ng-show="focus">
					<div class="fe-panel-editor-ico"></div>
					<div ng-repeat="Edit in pages">
						<div ng-include="'edit-'+Edit.temp+'.html'" ng-show="focus==Edit.id" Editid="{{Edit.id}}"></div>
					</div>
					<div ng-repeat="Edit in Items">
						<div ng-include="'edit-'+Edit.temp+'.html'" ng-show="focus==Edit.id" Editid="{{Edit.id}}"></div>
					</div>
				</div>
				<!-- editor end -->
			</div>
		</div>

		<!-- 页面底部保存栏 -->
		<div class="fe-save">
			<div class="fe-save-main">
				<div class="fe-save-info">
					<div class="fe-save-info-type fe-save-info-type-ok" data-type="1">
						{if $datas['pagetype']==1 || empty($datas['pagetype'])}
						<div class="fe-save-main-radio fe-save-main-radio2">√</div>
						{else}
						<div class="fe-save-main-radio"></div>
						{/if}
						<div class="fe-save-main-text">跑腿首页</div>
					</div>
					<input name="pagetype" type="hidden" value="{if empty($datas['pagetype'])}1{else}{$datas['pagetype']}{/if}" />
					<input name="pagename" type="text" style="height: 30px; width: 300px; border: 1px solid #bbb; border-radius: 3px; margin: 4px 10px; outline: none; padding-left: 10px;" placeholder="页面名称：快来给你的页面起一个响亮的名字" value="{$datas['pagename']}" />
				</div>
				<div class="fe-save-submit2" ng-click="save(2)">保存并预览</div>
				<div class="fe-save-submit" ng-click="save(1)">保存</div>
			</div>
			<div class="fe-save-fold" onclick="fold()"></div>
		</div>
	</div>

	<!-- editor template  page start -->
	<script type="text/ng-template" id="edit-topbar.html">
		<div class="fe-panel-editor-title">页面信息设置<span style="font-size: 12px; margin-left: 10px;"></span></div>
		<div class="fe-panel-editor-line">
			<div class="fe-panel-editor-name">页面标题</div>
			<div class="fe-panel-editor-con">
				<input class="fe-panel-editor-input1" placeholder="页面标题，手机端的页面标题，空则使用系统默认" ng-model="Edit.params.title" />
			</div>
		</div>
		<div class="fe-panel-editor-line">
			<div class="fe-panel-editor-name">页面描述</div>
			<div class="fe-panel-editor-con">
				<input class="fe-panel-editor-input1" placeholder="页面描述，手机端分享时显示，空则使用系统默认" ng-model="Edit.params.desc" />
			</div>
		</div>
		<div class="fe-panel-editor-line">
			<div class="fe-panel-editor-name">触发关键字</div>
			<div class="fe-panel-editor-con">
				<input class="fe-panel-editor-input1 keyword" placeholder="触发关键字" ng-model="Edit.params.kw" ng-change="keyword(Edit.params.kw,Edit.id)" />
			</div>
		</div>
		<div class="fe-panel-editor-line">
			<div class="fe-panel-editor-name">封面图片</div>
			<div class="fe-panel-editor-con">
				<div class="fe-panel-editor-upload" ng-click="pageImg(Edit.id,'img')" style="height:120px; width: 120px;">
					<img src="{{Edit.params.img}}" width="100%;" height="100%" ng-show="Edit.params.img" />
					<div class="fe-panel-editor-upload-choose2" ng-show="Edit.params.img">重新选择封面图</div>
					<div class="fe-panel-editor-upload-choose1" ng-show="!Edit.params.img" style="line-height:116px;"><i class="fa fa-plus-circle"></i> 选择图片</div>
				</div>
			</div>
		</div>
		<div class="fe-panel-editor-title">页面功能开关</div>
		<div class="fe-panel-editor-line">
			<div class="fe-panel-editor-name">底部导航</div>
			<div class="fe-panel-editor-con">
				<label style="cursor:pointer; margin-right: 10px;">
					<input type="radio" name="{{Edit.id}}_footer" value="1" ng-model="Edit.params.footer" /> 显示</label>
				<label style="cursor:pointer; margin-right: 10px;">
					<input type="radio" name="{{Edit.id}}_footer" value="0" ng-model="Edit.params.footer" /> 不显示</label>
			</div>
		</div>
		<div class="fe-panel-editor-line">
			<div class="fe-panel-editor-name">悬浮按钮</div>
			<div class="fe-panel-editor-con">
				<label style="cursor:pointer; margin-right: 10px;">
					<input type="radio" name="{{Edit.id}}_floatico" value="1" ng-model="Edit.params.floatico" /> 显示</label>
				<label style="cursor:pointer; margin-right: 10px;">
					<input type="radio" name="{{Edit.id}}_floatico" value="0" ng-model="Edit.params.floatico" /> 不显示</label>
				<span style="font-size: 12px; margin-left: 10px;">提示:在线客服推荐使用<a href="http://qiao.baidu.com" target="_blank">百度桥</a>可完美接入</span>
			</div>
		</div>
		<div class="fe-panel-editor-line">
			<div class="fe-panel-editor-name">关注按钮</div>
			<div class="fe-panel-editor-con">
				<label style="cursor:pointer; margin-right: 10px;">
					<input type="radio" name="{{Edit.id}}_guide" value="1" ng-model="Edit.params.guide" /> 显示</label>
				<label style="cursor:pointer; margin-right: 10px;">
					<input type="radio" name="{{Edit.id}}_guide" value="0" ng-model="Edit.params.guide" /> 不显示</label>
				<span style="font-size: 12px; margin-left: 10px;">提示:仅在未关注时显示</span>
			</div>
		</div>
		<div class="fe-panel-editor-title" ng-show="Edit.params.floatico==1">悬浮按钮设置</div>
		<div class="fe-panel-editor-line" ng-show="Edit.params.floatico==1">
			<div class="fe-panel-editor-name">图标位置</div>
			<div class="fe-panel-editor-con">
				<label style="cursor:pointer; margin-right: 10px;">
					<input type="radio" name="{{Edit.id}}_floatstyle" value="left" ng-model="Edit.params.floatstyle" /> 居左</label>
				<label style="cursor:pointer; margin-right: 10px;">
					<input type="radio" name="{{Edit.id}}_floatstyle" value="right" ng-model="Edit.params.floatstyle" /> 居右</label>
			</div>
		</div>
		<div class="fe-panel-editor-line" ng-show="Edit.params.floatico==1">
			<div class="fe-panel-editor-name">图标宽度</div>
			<div class="fe-panel-editor-con">
				<label style="cursor:pointer; margin-right: 10px;">
					<input type="radio" name="{{edit.id}}_floatwidth" value="30px" ng-model="Edit.params.floatwidth" /> 30像素</label>
				<label style="cursor:pointer; margin-right: 10px;">
					<input type="radio" name="{{edit.id}}_floatwidth" value="40px" ng-model="Edit.params.floatwidth" /> 40像素</label>
				<label style="cursor:pointer; margin-right: 10px;">
					<input type="radio" name="{{edit.id}}_floatwidth" value="50px" ng-model="Edit.params.floatwidth" /> 50像素</label>
				<label style="cursor:pointer; margin-right: 10px;">
					<input type="radio" name="{{edit.id}}_floatwidth" value="60px" ng-model="Edit.params.floatwidth" /> 60像素</label>
				<label style="cursor:pointer; margin-right: 10px;">
					<input type="radio" name="{{edit.id}}_floatwidth" value="80px" ng-model="Edit.params.floatwidth" /> 80像素</label>
				<label style="cursor:pointer; margin-right: 10px;">自定义：
					<input class="fe-panel-editor-input2" style="line-height: 20px;" value="" ng-model="Edit.params.floatwidth" />
				</label>
			</div>
		</div>
		<div class="fe-panel-editor-line" ng-show="Edit.params.floatico==1">
			<div class="fe-panel-editor-name">顶部间距</div>
			<div class="fe-panel-editor-con">
				<label style="cursor:pointer; margin-right: 10px;">
					<input type="radio" name="{{edit.id}}_floattop" value="80px" ng-model="Edit.params.floattop" /> 80像素</label>
				<label style="cursor:pointer; margin-right: 10px;">
					<input type="radio" name="{{edit.id}}_floattop" value="100px" ng-model="Edit.params.floattop" /> 100像素</label>
				<label style="cursor:pointer; margin-right: 10px;">
					<input type="radio" name="{{edit.id}}_floattop" value="120px" ng-model="Edit.params.floattop" /> 120像素</label>
				<label style="cursor:pointer; margin-right: 10px;">
					<input type="radio" name="{{edit.id}}_floattop" value="150px" ng-model="Edit.params.floattop" /> 150像素</label>
				<label style="cursor:pointer; margin-right: 10px;">
					<input type="radio" name="{{edit.id}}_floattop" value="180px" ng-model="Edit.params.floattop" /> 180像素</label>
				<label style="cursor:pointer; margin-right: 10px;">自定义：
					<input class="fe-panel-editor-input2" style="line-height: 20px;" value="" ng-model="Edit.params.floattop" />
				</label>
			</div>
		</div>
		<div class="fe-panel-editor-line" ng-show="Edit.params.floatico==1">
			<div class="fe-panel-editor-name">目标链接</div>
			<div class="fe-panel-editor-con">
				<input class="fe-panel-editor-input1" placeholder="此处只可填写链接，不可填写js代码 (请以http://开头)" ng-model="Edit.params.floathref" />
			</div>
		</div>
		<div class="fe-panel-editor-line" ng-show="Edit.params.floatico==1">
			<div class="fe-panel-editor-name">图标图片</div>
			<div class="fe-panel-editor-con">
				<div class="fe-panel-editor-upload" ng-click="pageImg(Edit.id,'floatimg')" style="min-height:120px; width: 50px;">
					<img src="{{Edit.params.floatimg}}" width="100%;" ng-show="Edit.params.floatimg" />
					<div class="fe-panel-editor-upload-choose2" ng-show="Edit.params.floatimg">重选</div>
					<div class="fe-panel-editor-upload-choose1" ng-show="!Edit.params.floatimg" style="line-height:116px;"><i class="fa fa-plus-circle"></i></div>
				</div>
			</div>
		</div>
		<div class="fe-panel-editor-title" ng-show="Edit.params.guide==1">关注按钮设置</div>
		<div class="fe-panel-editor-line" ng-show="Edit.params.guide==1">
			<div class="fe-panel-editor-name">默认标题1</div>
			<div class="fe-panel-editor-con">
				<input class="fe-panel-editor-input1" placeholder="默认标题1，用户访问商城首页或者邀请人不存在的时候显示" ng-model="Edit.params.guidetitle1" />
			</div>
		</div>
		<div class="fe-panel-editor-line" ng-show="Edit.params.guide==1">
			<div class="fe-panel-editor-name">默认标题2</div>
			<div class="fe-panel-editor-con">
				<input class="fe-panel-editor-input1" placeholder="默认标题2，用户访问商城首页或者推荐人不存在的时候显示" ng-model="Edit.params.guidetitle2" />
			</div>
		</div>
		<div class="fe-panel-editor-line" ng-show="Edit.params.guide==1">
			<div class="fe-panel-editor-name">邀请标题1</div>
			<div class="fe-panel-editor-con">
				<input class="fe-panel-editor-input1" placeholder="邀请标题1，用户被邀请进入商城时显示，可调用变量 [邀请人]、[访问者]" ng-model="Edit.params.guidetitle1s" />
			</div>
		</div>
		<div class="fe-panel-editor-line" ng-show="Edit.params.guide==1">
			<div class="fe-panel-editor-name">邀请标题2</div>
			<div class="fe-panel-editor-con">
				<input class="fe-panel-editor-input1" placeholder="邀请标题2，用户被邀请进入商城时显示，可调用变量 [邀请人]、[访问者]" ng-model="Edit.params.guidetitle2s" />
			</div>
		</div>
		<div class="fe-panel-editor-line" ng-show="Edit.params.guide==1">
			<div class="fe-panel-editor-name">按钮文字</div>
			<div class="fe-panel-editor-con">
				<input class="fe-panel-editor-input1" placeholder="按钮文字" ng-model="Edit.params.guidesub" />
			</div>
		</div>
		<div class="fe-panel-editor-line" ng-show="Edit.params.guide==1">
			<div class="fe-panel-editor-name">标题大小</div>
			<div class="fe-panel-editor-con">
				<label style="cursor:pointer; margin-right: 10px;">
					<input type="radio" name="{{edit.id}}_guidesize" value="8px" ng-model="Edit.params.guidesize" /> 8像素</label>
				<label style="cursor:pointer; margin-right: 10px;">
					<input type="radio" name="{{edit.id}}_guidesize" value="10px" ng-model="Edit.params.guidesize" /> 10像素</label>
				<label style="cursor:pointer; margin-right: 10px;">
					<input type="radio" name="{{edit.id}}_guidesize" value="12px" ng-model="Edit.params.guidesize" /> 12像素</label>
				<label style="cursor:pointer; margin-right: 10px;">
					<input type="radio" name="{{edit.id}}_guidesize" value="14px" ng-model="Edit.params.guidesize" /> 14像素</label>
				<label style="cursor:pointer; margin-right: 10px;">自定义：
					<input class="fe-panel-editor-input2" style="line-height: 20px;" value="" ng-model="Edit.params.guidesize" />
				</label>
			</div>
		</div>
		<div class="fe-panel-editor-line" ng-show="Edit.params.guide==1">
			<div class="fe-panel-editor-name">透明度</div>
			<div class="fe-panel-editor-con">
				<input class="fe-panel-editor-input2" type="text" ng-model="Edit.params.guideopacity">
				<span class="tips">例:0.8 (请填写0-1之间的数字) 建议填写0.9</span>
			</div>
		</div>
		<div class="fe-panel-editor-line" ng-show="Edit.params.guide==1">
			<div class="fe-panel-editor-name">标题颜色</div>
			<div class="fe-panel-editor-con">
				<input class="fe-panel-editor-input2" type="color" ng-model="Edit.params.guidecolor">
			</div>
		</div>
		<div class="fe-panel-editor-line" ng-show="Edit.params.guide==1">
			<div class="fe-panel-editor-name">背景颜色</div>
			<div class="fe-panel-editor-con">
				<input class="fe-panel-editor-input2" type="color" ng-model="Edit.params.guidebgcolor">
			</div>
		</div>
		<div class="fe-panel-editor-line" ng-show="Edit.params.guide==1">
			<div class="fe-panel-editor-name">按钮背景颜色</div>
			<div class="fe-panel-editor-con">
				<input class="fe-panel-editor-input2" type="color" ng-model="Edit.params.guidenavbgcolor">
			</div>
		</div>
		<div class="fe-panel-editor-line" ng-show="Edit.params.guide==1">
			<div class="fe-panel-editor-name">按钮文字颜色</div>
			<div class="fe-panel-editor-con">
				<input class="fe-panel-editor-input2" type="color" ng-model="Edit.params.guidenavcolor">
			</div>
		</div>
		<div class="fe-panel-editor-line" ng-show="Edit.params.guide==1">
			<div class="fe-panel-editor-name">头像样式</div>
			<div class="fe-panel-editor-con">
				<label style="cursor:pointer; margin-right: 10px;">
					<input type="radio" name="{{Edit.id}}_guidefacestyle" value="0px" ng-model="Edit.params.guidefacestyle" /> 正方形</label>
				<label style="cursor:pointer; margin-right: 10px;">
					<input type="radio" name="{{Edit.id}}_guidefacestyle" value="40px" ng-model="Edit.params.guidefacestyle" /> 正圆形</label>
			</div>
		</div>
	</script>
	<script type="text/ng-template" id="edit-notice.html">
		<div class="fe-panel-editor-title">公告设置<span class="tips">Tips:文字不滚动时超出宽度将隐藏</span></div>
		<div class="fe-panel-editor-line">
			<div class="fe-panel-editor-name">公告内容</div>
			<div class="fe-panel-editor-con">
				<input class="fe-panel-editor-input1" placeholder="这里填写公告内容，可设置是否滚动显示" ng-model="Edit.params.notice" />
			</div>
		</div>
		<div class="fe-panel-editor-line">
			<div class="fe-panel-editor-name">公告链接</div>
			<div class="fe-panel-editor-con">
				<input class="fe-panel-editor-input1" placeholder="请以http://开头(可链接至公众平台文章等)" ng-model="Edit.params.noticehref" />
			</div>
		</div>
		<div class="fe-panel-editor-line">
			<div class="fe-panel-editor-name">滚动显示</div>
			<div class="fe-panel-editor-con">
				<label style="cursor:pointer; margin-right: 10px;">
					<input type="radio" name="{{Edit.id}}_scroll" value="0" ng-model="Edit.params.scroll"> 不滚动</label>
				<label style="cursor:pointer; margin-right: 10px;">
					<input type="radio" name="{{Edit.id}}_scroll" value="1" ng-model="Edit.params.scroll"> 滚动显示</label>
			</div>
		</div>
		<div class="fe-panel-editor-line">
			<div class="fe-panel-editor-name">文字颜色</div>
			<div class="fe-panel-editor-con">
				<input class="fe-panel-editor-input2" type="color" ng-model="Edit.params.color" />
			</div>
		</div>
		<div class="fe-panel-editor-line">
			<div class="fe-panel-editor-name">背景颜色</div>
			<div class="fe-panel-editor-con">
				<input class="fe-panel-editor-input2" type="color" ng-model="Edit.params.bgcolor" />
			</div>
		</div>
	</script>
	<script type="text/ng-template" id="edit-menu.html">
		<div class="fe-panel-editor-title">按钮组设置<span class="tips">Tips:图片必须是正方形或者正圆形</span></div>
		<div class="fe-panel-editor-line">
			<div class="fe-panel-editor-name">图标样式</div>
			<div class="fe-panel-editor-con">
				<label style="cursor:pointer; margin-right: 10px;">
					<input type="radio" name="{{Edit.id}}_style" value="0" ng-model="Edit.params.style"> 正方形</label>
				<label style="cursor:pointer; margin-right: 10px;">
					<input type="radio" name="{{Edit.id}}_style" value="100%" ng-model="Edit.params.style"> 圆形</label>
			</div>
		</div>
		<div class="fe-panel-editor-line">
			<div class="fe-panel-editor-name">按钮数量</div>
			<div class="fe-panel-editor-con">
				<label style="cursor:pointer; margin-right: 10px;">
					<input type="radio" name="{{Edit.id}}_num" value="25%" ng-model="Edit.params.num" ng-change="setimg(Edit.id,Edit.params.num)"> 四个按钮</label>
				<label style="cursor:pointer; margin-right: 10px;">
					<input type="radio" name="{{Edit.id}}_num" value="20%" ng-model="Edit.params.num" ng-change="setimg(Edit.id,Edit.params.num)"> 五个按钮</label>
			</div>
		</div>
		<div class="fe-panel-editor-line">
			<div class="fe-panel-editor-name">背景颜色</div>
			<div class="fe-panel-editor-con">
				<input class="fe-panel-editor-input2" type="color" ng-model="Edit.params.bgcolor" />
			</div>
		</div>
		<div ng-repeat="menu in Edit.data" ng-hide="$index==4&&Edit.params.num=='25%'">
			<div class="fe-panel-editor-line2">
				<div class="fe-panel-editor-goodimg" ng-click="uploadImgChild(Edit.id,menu.id)" style="height:120px; width:120px;">
					<img src="{{menu.imgurl}}" width="100%" height="100%" ng-show="menu.imgurl" />
					<div class="fe-panel-editor-goodimg-t1" ng-show="!menu.imgurl" style="line-height:120px;"><i class="fa fa-plus-circle"></i> 选择图片</div>
					<div class="fe-panel-editor-goodimg-t2" ng-show="menu.imgurl" style="width:118px;">重新选择图片</div>
				</div>
				<div class="fe-panel-editor-line2-right">
					<div class="fe-panel-editor-line">
						<div class="fe-panel-editor-name">按钮文字</div>
						<div class="fe-panel-editor-con">
							<input class="fe-panel-editor-input1" style="width:400px;" value="" ng-model="menu.text" placeholder="请填写按钮文字" />
						</div>
					</div>
					<div class="fe-panel-editor-line">
						<div class="fe-panel-editor-name">链接地址</div>
						<div class="fe-panel-editor-con">
							<input class="fe-panel-editor-input3" value="" ng-model="menu.hrefurl" placeholder="请手动输入链接(请以http://开头)或选择系统链接" />
							<div class="fe-panel-editor-input4" ng-click="chooseUrl(Edit.id,menu.id)">系统连接</div>
						</div>
					</div>
					<div class="fe-panel-editor-line">
						<div class="fe-panel-editor-name">文字颜色</div>
						<div class="fe-panel-editor-con">
							<input class="fe-panel-editor-input2" type="color" ng-model="menu.color" />
						</div>
					</div>
				</div>
			</div>
		</div>
	</script>
	<script type="text/ng-template" id="edit-banner.html">
		<div class="fe-panel-editor-title">轮播设置<span class="tips">Tips:轮播图片的大小必须一样哦~</span></div>
		<div class="fe-panel-editor-line">
			<div class="fe-panel-editor-name">按钮形状</div>
			<div class="fe-panel-editor-con">
				<label style="cursor:pointer; margin-right: 10px;">
					<input type="radio" name="{{Edit.id}}_style" value="" ng-model="Edit.params.shape"> 长方形</label>
				<label style="cursor:pointer; margin-right: 10px;">
					<input type="radio" name="{{Edit.id}}_style" value="shape2" ng-model="Edit.params.shape"> 正方形</label>
				<label style="cursor:pointer; margin-right: 10px;">
					<input type="radio" name="{{Edit.id}}_style" value="shape3" ng-model="Edit.params.shape"> 圆形</label>
			</div>
		</div>
		<div class="fe-panel-editor-line">
			<div class="fe-panel-editor-name">按钮位置</div>
			<div class="fe-panel-editor-con">
				<label style="cursor:pointer; margin-right: 10px;">
					<input type="radio" name="{{Edit.id}}_align" value="left" ng-model="Edit.params.align"> 按钮居左</label>
				<label style="cursor:pointer; margin-right: 10px;">
					<input type="radio" name="{{Edit.id}}_align" value="center" ng-model="Edit.params.align"> 按钮居中</label>
				<label style="cursor:pointer; margin-right: 10px;">
					<input type="radio" name="{{Edit.id}}_align" value="right" ng-model="Edit.params.align"> 按钮居右</label>
			</div>
		</div>
		<div class="fe-panel-editor-line">
			<div class="fe-panel-editor-name">按钮颜色</div>
			<div class="fe-panel-editor-con">
				<input class="fe-panel-editor-input2" type="color" ng-model="Edit.params.bgcolor" />
			</div>
		</div>
		<div ng-repeat="banner in Edit.data" class="fe-panel-editor-relative">
			<div class="fe-panel-editor-del" title="移除" ng-click="delItemChild(Edit.id,banner.id)">×</div>
			<div class="fe-panel-editor-line2">
				<div class="fe-panel-editor-goodimg" ng-click="uploadImgChild(Edit.id,banner.id)">
					<img src="{{banner.imgurl}}" width="100%" ng-show="banner.imgurl" />
					<div class="fe-panel-editor-goodimg-t1" ng-show="!banner.imgurl"><i class="fa fa-plus-circle"></i> 选择图片</div>
					<div class="fe-panel-editor-goodimg-t2" ng-show="banner.imgurl">重新选择图片</div>
				</div>
				<div class="fe-panel-editor-line2-right">
					<div class="fe-panel-editor-line">
						<div class="fe-panel-editor-name">选择链接</div>
						<div class="fe-panel-editor-con">
							<input class="fe-panel-editor-input3" value="" ng-model="banner.hrefurl" placeholder="请手动输入链接(请以http://开头)或选择系统链接" />
							<div class="fe-panel-editor-input4" ng-click="chooseUrl(Edit.id,banner.id)">系统连接</div>
						</div>
					</div>
				</div>
			</div>
		</div>
		<div class="fe-panel-editor-sub1" ng-click="addItemChild('banner',Edit.id)"><i class="fa fa-plus-circle"></i> 添加一个轮播</div>
	</script>
	<script type="text/ng-template" id="edit-picture.html">
		<div class="fe-panel-editor-title">单图设置<span class="tips">Tips:图片最低高度为40像素</span></div>
		<div ng-repeat="picture in Edit.data" class="fe-panel-editor-relative">
			<div class="fe-panel-editor-del" title="移除" ng-click="delItemChild(Edit.id,picture.id)">×</div>
			<div class="fe-panel-editor-line2">
				<div class="fe-panel-editor-goodimg" ng-click="uploadImgChild(Edit.id,picture.id)">
					<img src="{{picture.imgurl}}" width="100%" ng-show="picture.imgurl" />
					<div class="fe-panel-editor-goodimg-t1" ng-show="!picture.imgurl"><i class="fa fa-plus-circle"></i> 选择图片</div>
					<div class="fe-panel-editor-goodimg-t2" ng-show="picture.imgurl">重新选择图片</div>
				</div>
				<div class="fe-panel-editor-line2-right">
					<div class="fe-panel-editor-line">
						<div class="fe-panel-editor-name">链接地址</div>
						<div class="fe-panel-editor-con">
							<input class="fe-panel-editor-input3" value="" ng-model="picture.hrefurl" placeholder="请手动输入链接(请以http://开头)或选择系统链接" />
							<div class="fe-panel-editor-input4" ng-click="chooseUrl(Edit.id,picture.id)">系统连接</div>
						</div>
					</div>
				</div>
			</div>
		</div>
		<div class="fe-panel-editor-sub1" ng-click="addItemChild('picture',Edit.id)"><i class="fa fa-plus-circle"></i> 添加一个单图</div>
	</script>
	<script type="text/ng-template" id="edit-title.html">
		<div class="fe-panel-editor-title">标题设置</div>
		<div class="fe-panel-editor-line">
			<div class="fe-panel-editor-name">主标题内容</div>
			<div class="fe-panel-editor-con">
				<input class="fe-panel-editor-input1" placeholder="标题模块的主标题，超出屏幕宽度将自动隐藏" ng-model="Edit.params.title1" />
			</div>
		</div>
		<div class="fe-panel-editor-line">
			<div class="fe-panel-editor-name">主标题大小</div>
			<div class="fe-panel-editor-con">
				<label style="cursor:pointer; margin-right: 10px;">
					<input type="radio" name="{{edit.id}}_fontsize1" value="12px" ng-model="Edit.params.fontsize1" /> 12像素</label>
				<label style="cursor:pointer; margin-right: 10px;">
					<input type="radio" name="{{edit.id}}_fontsize1" value="14px" ng-model="Edit.params.fontsize1" /> 14像素</label>
				<label style="cursor:pointer; margin-right: 10px;">
					<input type="radio" name="{{edit.id}}_fontsize1" value="16px" ng-model="Edit.params.fontsize1" /> 16像素</label>
				<label style="cursor:pointer; margin-right: 10px;">
					<input type="radio" name="{{edit.id}}_fontsize1" value="18px" ng-model="Edit.params.fontsize1" /> 18像素</label>
				<label style="cursor:pointer; margin-right: 10px;">
					<input type="radio" name="{{edit.id}}_fontsize1" value="20px" ng-model="Edit.params.fontsize1" /> 20像素</label>
				<label style="cursor:pointer; margin-right: 10px;">自定义：
					<input class="fe-panel-editor-input2" style="line-height: 20px;" value="" ng-model="Edit.params.fontsize1" />
				</label>
			</div>
		</div>
		<div class="fe-panel-editor-line">
			<div class="fe-panel-editor-name">显示副标题</div>
			<div class="fe-panel-editor-con">
				<label style="cursor:pointer; margin-right: 10px;">
					<input type="radio" name="{{Edit.id}}_showtitle2" value="1" ng-model="Edit.params.showtitle2" /> 显示</label>
				<label style="cursor:pointer; margin-right: 10px;">
					<input type="radio" name="{{Edit.id}}_showtitle2" value="0" ng-model="Edit.params.showtitle2" /> 不显示</label>
			</div>
		</div>
		<div class="fe-panel-editor-line" ng-show="Edit.params.showtitle2==1">
			<div class="fe-panel-editor-name">副标题内容</div>
			<div class="fe-panel-editor-con">
				<input class="fe-panel-editor-input1" placeholder="标题模块的副标题，超出屏幕宽度将自动隐藏" ng-model="Edit.params.title2" />
			</div>
		</div>
		<div class="fe-panel-editor-line" ng-show="Edit.params.showtitle2==1">
			<div class="fe-panel-editor-name">副标题大小</div>
			<div class="fe-panel-editor-con">
				<label style="cursor:pointer; margin-right: 10px;">
					<input type="radio" name="{{edit.id}}_fontsize2" value="12px" ng-model="Edit.params.fontsize2" /> 12像素</label>
				<label style="cursor:pointer; margin-right: 10px;">
					<input type="radio" name="{{edit.id}}_fontsize2" value="14px" ng-model="Edit.params.fontsize2" /> 14像素</label>
				<label style="cursor:pointer; margin-right: 10px;">
					<input type="radio" name="{{edit.id}}_fontsize2" value="16px" ng-model="Edit.params.fontsize2" /> 16像素</label>
				<label style="cursor:pointer; margin-right: 10px;">
					<input type="radio" name="{{edit.id}}_fontsize2" value="18px" ng-model="Edit.params.fontsize2" /> 18像素</label>
				<label style="cursor:pointer; margin-right: 10px;">
					<input type="radio" name="{{edit.id}}_fontsize2" value="20px" ng-model="Edit.params.fontsize2" /> 20像素</label>
				<label style="cursor:pointer; margin-right: 10px;">自定义：
					<input class="fe-panel-editor-input2" style="line-height: 20px;" value="" ng-model="Edit.params.fontsize2" />
				</label>
			</div>
		</div>
		<div class="fe-panel-editor-line">
			<div class="fe-panel-editor-name">对齐方向</div>
			<div class="fe-panel-editor-con">
				<label style="cursor:pointer; margin-right: 10px;">
					<input type="radio" name="{{Edit.id}}_align" value="left" ng-model="Edit.params.align" /> 居左</label>
				<label style="cursor:pointer; margin-right: 10px;">
					<input type="radio" name="{{Edit.id}}_align" value="center" ng-model="Edit.params.align" /> 居中</label>
				<label style="cursor:pointer; margin-right: 10px;">
					<input type="radio" name="{{Edit.id}}_align" value="right" ng-model="Edit.params.align" /> 居右</label>
			</div>
		</div>
		<div class="fe-panel-editor-line">
			<div class="fe-panel-editor-name">文字颜色</div>
			<div class="fe-panel-editor-con">
				<input class="fe-panel-editor-input2" type="color" ng-model="Edit.params.color" />
			</div>
		</div>
		<div class="fe-panel-editor-line">
			<div class="fe-panel-editor-name">背景颜色</div>
			<div class="fe-panel-editor-con">
				<input class="fe-panel-editor-input2" type="color" ng-model="Edit.params.bgcolor" />
			</div>
		</div>
	</script>
	<script type="text/ng-template" id="edit-search.html">
		<div class="fe-panel-editor-title">搜索框设置</div>
		<div class="fe-panel-editor-line">
			<div class="fe-panel-editor-name">提示文字</div>
			<div class="fe-panel-editor-con">
				<input class="fe-panel-editor-input1" placeholder="搜索框默认提示文字，超出屏幕宽度将自动隐藏" ng-model="Edit.params.placeholder" />
			</div>
		</div>
		<div class="fe-panel-editor-line">
			<div class="fe-panel-editor-name">选择样式</div>
			<div class="fe-panel-editor-con">
				<label style="cursor:pointer; margin-right: 10px;">
					<input type="radio" name="{{Edit.id}}_style" value="style1" ng-model="Edit.params.style"> 样式一</label>
			</div>
		</div>
	</script>
	<script type="text/ng-template" id="edit-line.html">
		<div class="fe-panel-editor-title">辅助线设置</div>
		<div class="fe-panel-editor-line">
			<div class="fe-panel-editor-name">选择样式</div>
			<div class="fe-panel-editor-con">
				<label style="cursor:pointer; margin-right: 10px;">
					<input type="radio" name="{{Edit.id}}_style" value="solid" ng-model="Edit.params.style" /> 实线</label>
				<label style="cursor:pointer; margin-right: 10px;">
					<input type="radio" name="{{Edit.id}}_style" value="dashed" ng-model="Edit.params.style" /> 虚线</label>
				<label style="cursor:pointer; margin-right: 10px;">
					<input type="radio" name="{{Edit.id}}_style" value="dotted" ng-model="Edit.params.style" /> 圆点</label>
			</div>
		</div>
		<div class="fe-panel-editor-line">
			<div class="fe-panel-editor-name">选择高度</div>
			<div class="fe-panel-editor-con">
				<label style="cursor:pointer; margin-right: 10px;">
					<input type="radio" name="{{edit.id}}_height" value="1px" ng-model="Edit.params.height" /> 1像素</label>
				<label style="cursor:pointer; margin-right: 10px;">
					<input type="radio" name="{{edit.id}}_height" value="2px" ng-model="Edit.params.height" /> 2像素</label>
				<label style="cursor:pointer; margin-right: 10px;">
					<input type="radio" name="{{edit.id}}_height" value="5px" ng-model="Edit.params.height" /> 5像素</label>
				<label style="cursor:pointer; margin-right: 10px;">
					<input type="radio" name="{{edit.id}}_height" value="10px" ng-model="Edit.params.height" /> 10像素</label>
				<label style="cursor:pointer; margin-right: 10px;">
					<input type="radio" name="{{edit.id}}_height" value="20px" ng-model="Edit.params.height" /> 20像素</label>
				<label style="cursor:pointer; margin-right: 10px;">自定义：
					<input class="fe-panel-editor-input2" style="line-height: 20px;" value="" ng-model="Edit.params.height" />
				</label>
			</div>
		</div>
		<div class="fe-panel-editor-line">
			<div class="fe-panel-editor-name">设置颜色</div>
			<div class="fe-panel-editor-con">
				<input class="fe-panel-editor-input2" type="color" ng-model="Edit.params.color">
			</div>
		</div>
	</script>
	<script type="text/ng-template" id="edit-blank.html">
		<div class="fe-panel-editor-title">辅助空白设置</div>
		<div class="fe-panel-editor-line">
			<div class="fe-panel-editor-name">选择高度</div>
			<div class="fe-panel-editor-con">
				<label style="cursor:pointer; margin-right: 10px;">
					<input type="radio" name="{{Edit.id}}_height" value="10px" ng-model="Edit.params.height" /> 10像素</label>
				<label style="cursor:pointer; margin-right: 10px;">
					<input type="radio" name="{{Edit.id}}_height" value="20px" ng-model="Edit.params.height" /> 20像素</label>
				<label style="cursor:pointer; margin-right: 10px;">
					<input type="radio" name="{{Edit.id}}_height" value="50px" ng-model="Edit.params.height" /> 50像素</label>
				<label style="cursor:pointer; margin-right: 10px;">
					<input type="radio" name="{{Edit.id}}_height" value="100px" ng-model="Edit.params.height" /> 100像素</label>
				<label style="cursor:pointer; margin-right: 10px;">
					<input type="radio" name="{{Edit.id}}_height" value="150px" ng-model="Edit.params.height" /> 150像素</label>
				<label style="cursor:pointer; margin-right: 10px;">自定义：
					<input class="fe-panel-editor-input2" style="line-height: 20px;" ng-model="Edit.params.height" />
				</label>
			</div>
		</div>
		<div class="fe-panel-editor-line">
			<div class="fe-panel-editor-name">背景颜色</div>
			<div class="fe-panel-editor-con">
				<input class="fe-panel-editor-input2" type="color" ng-model="Edit.params.bgcolor" />
			</div>
		</div>
	</script>
	<script type="text/ng-template" id="edit-richtext.html">
		<div class="fe-panel-editor-title">富文本设置</div>
		<div class="fe-panel-editor-line">
			<div class="fe-panel-editor-name">背景颜色</div>
			<div class="fe-panel-editor-con">
				<input class="fe-panel-editor-input2" type="color" ng-model="Edit.params.bgcolor">
			</div>
		</div>
		<div class="ueditor" ng-model="Edit.content" style="height:400px; width:100%; margin-top:10px;"></div>
	</script>
	<!-- editor template page end -->
</div>

<!-- 预览 end -->
<script src="//cdn.bootcss.com/angular.js/1.5.5/angular.min.js"></script>
<script type="text/javascript" src="../addons/imeepos_runner/plugin/template/template/static/angular-ueditor.js"></script>
<script type="text/javascript" src="../addons/imeepos_runner/plugin/template/template/static/hhSwipe.js"></script>
<script type="text/javascript" src="./resource/components/ueditor/ueditor.config.js"></script>
<script type="text/javascript" src="./resource/components/ueditor/ueditor.all.min.js"></script>
<script type="text/javascript" src="./resource/components/ueditor/ueditor.parse.js"></script>
<script type="text/javascript" src="./resource/components/ueditor/lang/zh-cn/zh-cn.js"></script>


<script>
	$(function() {
		require(['util'], function(util) {
			var preview_id = util.cookie.get('preview_id');
			if (preview_id) {
				preview(preview_id);
			}
		});
		
		$(".fe-save-info-type-ok").click(function() {
			var pagetype = $(this).data("type");
			if (pagetype != '2' || pagetype != '3') {
				$(this).find(".fe-save-main-radio").addClass("fe-save-main-radio2").text("√");
				$(this).siblings().find(".fe-save-main-radio").removeClass("fe-save-main-radio2").text("");
			}
			$("input[name=pagetype]").val(pagetype);
		});
	});

	function switchtab(tag, n) {
		$("#" + tag + "-" + n).fadeIn().siblings().hide();
		$("#" + tag + "-nav-" + n).addClass("active").siblings().removeClass("active");
	}

	function fold() {
		width = $(".fe-save").width();
		left = $(".fe-save").css("left");
		left = left.replace("px", "");
		if (left >= 0) {
			$(".fe-save").animate({
				left: 0 - width + 40 + "px"
			}, 1000);
			$(".fe-save-fold").addClass("fe-save-fold2");
		} else {
			$(".fe-save").animate({
				left: "0px"
			}, 1000);
			$(".fe-save-fold").removeClass("fe-save-fold2");
		}
	}

	function setcookie(id) {
		require(['util'], function(util) {
			util.cookie.set('preview_id', id);
		});
	}

	function clone(myObj) {
		if (typeof(myObj) != 'object' || myObj == null) return myObj;
		var newObj = new Object();
		for (var i in myObj) {
			newObj[i] = clone(myObj[i]);
		}
		return newObj;
	}

	function cloneArr(arr) {
		var newArr = [];
		$(arr).each(function(i, val) {
			newArr.push(clone(val));
		});
		return newArr;
	}

	function initswipe(jobj) {
		var bullets = jobj.next().get(0).getElementsByTagName('a');
		var banner = Swipe(jobj.get(0), {
			auto: 2000,
			continuous: true,
			disableScroll: false,
			callback: function(pos) {
				var i = bullets.length;
				while (i--) {
					bullets[i].className = '';
				}
				bullets[pos].className = 'cur';
			}
		})
	}
	
	var myModel = angular.module('FoxEditor', ['ng.ueditor']);
	myModel.controller('FoxController', ['$scope', function($scope) {
		// 1.1 添加一条子级(good,picture,banner)
		$scope.addItemChild = function(type, Mid) {
				if (type && Mid) {
					t = '';
					if (type == 'good') {
						t = 'G';
					} else if (type == 'picture') {
						t = 'P';
					} else if (type == 'banner') {
						t = 'B';
					}
					var var_id = t + new Date().getTime();
					var push = {
						banner: {
							id: var_id,
							imgurl: '',
							hrefurl: '',
							sysurl: 'url'
						},
						picture: {
							id: var_id,
							imgurl: '',
							hrefurl: '',
							option: '0'
						},
						good: {}
					};
					var Items = $scope.Items;
					angular.forEach(Items, function(m, index) {
						if (m.id == Mid) {
							m.data.push(push[type]);
							//console.log(push[type]);
						}
					});
				}
			}
			// 1.1 删除一条子级
		$scope.delItemChild = function(Mid, Cid) {
				if (confirm("此操作不可逆，确认移除？")) {
					var Items = $scope.Items;
					angular.forEach(Items, function(m, index1) {
						if (m.id == Mid) {
							angular.forEach(m.data, function(c, index2) {
								if (c.id == Cid) {
									m.data.splice(index2, 1);
								}
							});
						}
					});
				}
			}
			// 1.1 上传图片
		$scope.uploadImgChild = function(Mid, Cid) {
				require(['jquery', 'util'], function($, util) {
					util.image('', function(data) {
						var Items = $scope.Items;
						angular.forEach(Items, function(m, index1) {
							if (m.id == Mid) {
								console.log(Items);
								angular.forEach(m.data, function(c, index2) {
									if (c.id == Cid) {
										c.imgurl = data['url'];
										$("div[mid=" + Mid + "]").mouseover();
										//console.log(Items);
									}
								});
							}
						});
					});
				});
			}
			// 1.1 选择链接
		$scope.chooseUrl = function(Mid, Cid) {
			$('#floating-link').attr({
				"Mid": Mid,
				"Cid": Cid
			});
			$('#floating-link').modal();
		}
		$scope.chooseLink = function(type, hid) {
			Mid = $('#floating-link').attr("Mid");
			Cid = $('#floating-link').attr("Cid");
			url = $("#fe-tab-link-" + type + " #fe-tab-link-li-" + hid).data("href");
			if (url && Mid && Cid) {
				angular.forEach($scope.Items, function(m, index1) {
					if (m.id == Mid) {
						angular.forEach(m.data, function(c, index2) {
							if (c.id == Cid) {
								c.hrefurl = url;
							}
						})
					}
				});
				$('#floating-link .close').click();
			}
		}
		$scope.temp = {
			notcie: []
		};
		$scope.ajaxselect = function(type) {
			val = $("#select-" + type + "-kw").val();
			mid = $("#floating-link").attr("mid");
			$.ajax({
				type: 'post',
				dataType: 'json',
				url: "{php echo $this->createWebPluginUrl('system/themes',array('op'=>'api','apido'=>'selectlink'))}",
				data: {
					kw: val,
					type: type
				},
				success: function(data) {
					$scope.temp[type] = data;
					$("div [mid=" + mid + "]").mouseover();
				},
				error: function() {
					alert('查询失败！请刷新页面。');
				}
			});
			console.log($scope.temp.notice);
		}
		$scope.focus = 'M0000000000000';
		
		$scope.keyword = function(val, Eid) {
			$.ajax({
				type: 'post',
				url: "{php echo $this->createWebPluginUrl('system/themes',array('op'=>'api','apido'=>'selectkeyword'))}",
				data: {
					kw: val,
					pid: "{$pageid}"
				},
				success: function(data) {
					if (data != 'ok') {
						window.dosave = '1';
						$("div[Editid=" + Eid + "]").find(".keyword").css('border', "#f01 solid 1px");
					} else {
						window.dosave = '0';
						$("div[Editid=" + Eid + "]").find(".keyword").css('border', "#ddd solid 1px");
					}
				},
				error: function() {
					alert('查询商品信息失败！请刷新页面。');
				}
			});
		}
		
		$scope.selectgood = function(Mid) {
			kw = $("#secect-kw").val();
			$.ajax({
				type: 'post',
				dataType: 'json',
				url: "{php echo $this->createWebPluginUrl('system/themes',array('op'=>'api','apido'=>'selectgood'))}",
				data: {
					kw: kw
				},
				success: function(data) {
					$scope.selectGoods = [];
					angular.forEach(data, function(d, i) {
						Sid = 'S' + new Date().getTime();
						$scope.selectGoods.push({
							id: Sid + i,
							name: data[i].title,
							img: data[i].thumb,
							goodid: data[i].id,
							pricenow: data[i].marketprice,
							priceold: data[i].productprice
						});
					});
					$("div[mid=" + Mid + "]").mouseover();
				},
				error: function() {
					alert('查询商品信息失败！请刷新页面。');
				}
			});
		}
		
		$scope.pushGood = function(Mid, Sid) {
			var repaction = $('#floating-good').attr("action");
			var repGid = $('#floating-good').attr("Gid");
			angular.forEach($scope.Items, function(m, index1) {
				if (m.id == Mid) {
					angular.forEach($scope.selectGoods, function(s, index2) {
						if (s.id == Sid) {
							if (repaction == 'replace' && repGid) {
								// 执行替换
								angular.forEach(m.data, function(r, index3) {
									if (r.id == repGid) {
										var Gid = 'G' + new Date().getTime();
										r.id = Gid;
										r.img = s.img;
										r.goodid = s.goodid;
										r.name = s.name;
										r.priceold = s.priceold;
										r.pricenow = s.pricenow;
										$('#floating-good .close').click();
									}
								});
							} else if (!repaction) {
								var Gid = 'G' + new Date().getTime();
								// 执行添加
								m.data.push({
									id: Gid,
									img: s.img,
									goodid: s.goodid,
									name: s.name,
									priceold: s.priceold,
									pricenow: s.pricenow
								});
							}
						}
					});
				}
			});
		}
		$scope.selectGoods = [];
		$scope.navs = {php echo json_encode($navs)};
		
		$scope.shop = {uniacid: '{$_W["uniacid"]}'};
		$scope.system = [{$system}];
		$scope.pages = [{php echo json_encode($pageinfo)}];
		$scope.Items = [{$data}];
		$scope.load = function() {}
		
		$scope.changeImg = function(Mid, n) {
			width = $(".fe-mod-move").width();
			n = n.replace("%", "");
			n = n / 100;
			$("div[mid=" + Mid + "] .fe-mod-8-main-img img").height(width * n - 10);
		};
		
		$scope.setimg = function(Mid, n) {
			width = $(".fe-mod-move").width();
			n = n.replace("%", "");
			n = n / 100;
			$("div[mid=" + Mid + "] .fe-mod-12 img").height(width * n - 30);
		}
		
		$scope.setfocus = function(Mid, e) {
			$scope.focus = Mid;
			ccc = $("div[id=" + Mid + "]").offset().top;
			ddd = (ccc - 370) >= 0 ? (ccc - 370) : 0;
			$(".fe-panel-editor").css("margin-top", ddd + "px");
		}
		
		$scope.drag = function(Mid) {
			var container = $("#editor");
			var del = container.find(".fe-mod-move");
			del.off("mousedown").mousedown(function(e) {
				$scope.focus = Mid;
				if (e.which != 1 || $(e.target).is("textarea") || window.kp_only) return;
				e.preventDefault();
				var x = e.pageX;
				var y = e.pageY;
				var _this = $(this).parent();
				var w = _this.width();
				var h = _this.height();
				var w2 = w / 2;
				var h2 = h / 2;
				var p = _this.position();
				var left = p.left;
				var top = p.top;
				window.kp_only = true;
				_this.before('<div id="kp_widget_holder"></div>');
				var wid = $("#kp_widget_holder");
				var nod = $(".fe-mod-nodrag");
				wid.css({
					"border": "2px dashed #ccc",
					"height": _this.outerHeight(true)
				});
				_this.css({
					"width": w,
					"height": h,
					"position": "absolute",
					opacity: 0.8,
					"z-index": 900,
					"left": left,
					"top": top
				});
				$(document).mousemove(function(e) {
					$scope.focus = Mid;
					e.preventDefault();
					var l = left + e.pageX - x;
					var t = top + e.pageY - y;
					_this.css({
						"left": l,
						"top": t
					});
					var ml = l + w2;
					var mt = t + h2;
					del.parent().not(_this).not(wid).each(function(i) {
						var obj = $(this);
						var p = obj.position();
						var a1 = p.left;
						var a2 = p.left + obj.width();
						var a3 = p.top;
						var a4 = p.top + obj.height();
						if (a1 < ml && ml < a2 && a3 < mt && mt < a4) {
							if (!obj.next("#kp_widget_holder").length) {
								wid.insertAfter(this);
							} else {
								wid.insertBefore(this);
							}
							return;
						}
					});
				});
				$(document).mouseup(function() {
					$(document).off('mouseup').off('mousemove');
					$(container).each(function() {
						var obj = $(this).children();
						var len = obj.length;
						if (len == 1 && obj.is(_this)) {
							$("<div></div>").appendTo(this).attr("class", "kp_widget_block").css({
								"height": 100
							});
						} else if (len == 2 && obj.is(".kp_widget_block")) {
							$(this).children(".kp_widget_block").remove();
						}
					});
					var p = wid.position();
					_this.animate({
						"left": p.left,
						"top": p.top
					}, 100, function() {
						_this.removeAttr("style");
						wid.replaceWith(_this);
						window.kp_only = null;
						var arr = [];
						$(".fe-mod-repeat").find(".fe-mod-parent").each(function(i, val) {
							arr[i] = val.id;
						});
						var newarr = [];
						angular.forEach(arr, function(aid) {
							angular.forEach($scope.Items, function(obj) {
								if (obj.id == aid) {
									newarr.push(obj);
									return false;
								}
							});
						});
						$scope.Items = newarr;
					});
				});
			});
		}
		
		$scope.addItem = function(Nid) {
			var Mid = 'M' + new Date().getTime();
			var Navs = $scope.navs;
			angular.forEach(Navs, function(n, index) {
				if (n.id == Nid) {
					newparams = !clone(n.params) ? '' : clone(n.params);
					newdata = !n.data ? '' : cloneArr(n.data);
					newother = !clone(n.other) ? '' : clone(n.other);
					newcontent = !clone(n.content) ? '' : clone(n.content);
					$scope.Items.push({
						id: Mid,
						temp: Nid,
						params: newparams,
						data: newdata,
						other: newother,
						content: newcontent
					});
					console.log($scope.Items);
				}
			});
		}
		
		$scope.delItem = function(id) {
			if (confirm("此操作不可逆，确认移除？")) {
				var Items = $scope.Items;
				angular.forEach(Items, function(a, index) {
					if (a.id == id) {
						Items.splice(index, 1);
						$scope.focus = '';
					}
				});
			}
		}
		
		$scope.over = function(id) {
			$("div[id=" + id + "]").parent().find(".fe-mod-del").stop().show();
		}
		
		$scope.out = function(id) {
			$("div[id=" + id + "]").parent().find(".fe-mod-del").stop().hide();
		}
		
		$scope.save = function(n) {
			var pageid = "{$pageid}";
			var items = cloneArr($scope.Items);
			angular.forEach(items, function(m, index1) {
				if (m.temp == 'richtext') {
					m.content = escape(m.content);
				}
			});
			var datas = angular.toJson(items);
			var pageinfo = angular.toJson($scope.pages);
			var pagename = $("input[name=pagename]").val();
			var pagetype = $("input[name=pagetype]").val();
			if (!pagename) {
				alert('请给你的页面起一个响亮的名字吧');
				return;
			}
			if (!pagetype) {
				alert('你还没有选择页面的类型哦~');
				return;
			}
			if (window.dosave == '1') {
				alert('触发关键字已存在！请重新填写。');
				$scope.focus = 'M0000000000000';
				return;
			}
			$(".fe-save-submit").text('保存中...').addClass("fe-save-disabled").data('saving', '1');
			$(".fe-save-submit2").css("color", "#bbb");
			if ($(".fe-save-submit").data('saving') == 1) {
				$.ajax({
					type: 'POST',
					url: "{php echo $this->createWebPluginUrl('system/themes',array('op'=>'api','apido'=>'savepage'))}",
					data: {
						pageid: pageid,
						datas: datas,
						pagetype: pagetype,
						pagename: pagename,
						pageinfo: pageinfo
					},
					success: function(data) {
						if (n == 2) {
							alert("保存成功！正在生成览页面...");
							setcookie(data);
							if (!pageid) {
								location.href = "{php echo $this->createWebPluginUrl('system/themes',array('op'=>'post'))}&pageid=" + data;
							} else {
								preview(data);
							}
						} else {
							alert("保存成功！");
							if (!pageid) {
								location.href = "{php echo $this->createWebPluginUrl('system/themes',array('op'=>'post'))}&pageid=" + data;
							}
						}
						$(".fe-save-submit").text('保存').removeClass("fe-save-disabled").data('saving', '0');
						$(".fe-save-submit2").css("color", "#4bb5fb")
					},
					error: function() {
						alert('保存失败请重试');
						$(".fe-save-submit").text('保存').removeClass("fe-save-disabled").data('saving', '0');
						$(".fe-save-submit2").css("color", "#4bb5fb")
					}
				});
			}
		}
		
		$scope.addGood = function(action, Mid, Gid) {
			$('#floating-good').modal();
			$('#floating-good').attr({
				'action': action,
				'Gid': Gid
			});
		}
		
		$scope.delGood = function(Mid, Gid) {
			if (confirm("此操作不可逆，确认移除？")) {
				var Items = $scope.Items;
				angular.forEach(Items, function(m, index1) {
					if (m.id == Mid) {
						angular.forEach(m.data, function(g, index2) {
							if (g.id == Gid) {
								m.data.splice(index2, 1);
							}
						});
					}
				});
			}
		}
		
		$scope.shopImg = function(Mid) {
			require(['jquery', 'util'], function($, util) {
				util.image('', function(data) {
					var Items = $scope.Items;
					angular.forEach(Items, function(m, index1) {
						if (m.id == Mid) {
							m.params.bgimg = data['url'];
							$("div[mid=" + Mid + "]").mouseover();
						}
					});
				});
			});
		}
		
		$scope.pageImg = function(Mid, type) {
			require(['jquery', 'util'], function($, util) {
				util.image('', function(data) {
					if (type == 'floatimg') {
						$scope.pages[0].params.floatimg = data['url'];
					} else {
						$scope.pages[0].params.img = data['url'];
					}
					$("div[mid=" + Mid + "]").trigger("click");
				});
			});
		}
		$scope.$on('ngRepeatFinished', function(ngRepeatFinishedEvent) {
			$('.fe-mod-2 .swipe').each(function() {
				initswipe($(this));
			})
			$('.fe-mod-8-main-img img').each(function() {
				$(this).height($(this).width());
			});
			$('.fe-mod-12 img').each(function() {
				$(this).height($(this).width());
			});
		});
	}]);
	
	myModel.directive('stringHtml', function() {
		return function(scope, el, attr) {
			if (attr.stringHtml) {
				scope.$watch(attr.stringHtml, function(html) {
					el.html(html || '');
				});
			}
		};
	});
	myModel.directive("onFinishRenderFilters", function($timeout) {
		return {
			restrict: 'A',
			link: function(scope, element, attr) {
				if (scope.$last === true) {
					$timeout(function() {
						scope.$emit('ngRepeatFinished');
					});
				}
			}
		};
	});
</script>
<script type="text/javascript">
	// 百度编辑器初始化
	var opts = {
		type: 'image',
		direct: false,
		multi: true,
		tabs: {
			'upload': 'active',
			'browser': '',
			'crawler': ''
		},
		path: '',
		dest_dir: '',
		global: false,
		thumb: false,
		width: 0
	};
	UE.registerUI('myinsertimage', function(editor, uiName) {
			editor.registerCommand(uiName, {
				execCommand: function() {
					require(['fileUploader'],
						function(uploader) {
							uploader.show(function(imgs) {
									if (imgs.length == 0) {
										return;
									} else if (imgs.length == 1) {
										editor.execCommand('insertimage', {
											'src': imgs[0]['url'],
											'_src': imgs[0]['attachment'],
											'width': '100%',
											'alt': imgs[0].filename
										});
									} else {
										var imglist = [];
										for (i in imgs) {
											imglist.push({
												'src': imgs[i]['url'],
												'_src': imgs[i]['attachment'],
												'width': '100%',
												'alt': imgs[i].filename
											});
										}
										editor.execCommand('insertimage', imglist);
									}
								},
								opts);
						});
				}
			});
			var btn = new UE.ui.Button({
				name: '插入图片',
				title: '插入图片',
				cssRules: 'background-position: -726px -77px',
				onclick: function() {
					editor.execCommand(uiName);
				}
			});
			editor.addListener('selectionchange',
				function() {
					var state = editor.queryCommandState(uiName);
					if (state == -1) {
						btn.setDisabled(true);
						btn.setChecked(false);
					} else {
						btn.setDisabled(false);
						btn.setChecked(state);
					}
				});
			return btn;
		},
		19);
</script>
{template 'common/footer'}